package com.chen.deskclock.ScheduleManagement;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TimePicker;
import android.widget.Toast;

import com.chen.deskclock.R;
import com.chen.deskclock.settings.ScheduleManagementActivity;

public class StartPage1 extends AppCompatActivity {
    private TimePicker timePicker;
private Button btn1;
private Button btn2;
//睡觉时间信息
private Integer Hour;
private Integer Minute;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start_page1);
        btn1=findViewById(R.id.back_step);
        btn2=findViewById(R.id.continue_step);
        timePicker=findViewById(R.id.time_picker);
        timePicker.setIs24HourView(true);
        timePicker.setDescendantFocusability(DatePicker.FOCUS_BLOCK_DESCENDANTS);
        timePicker.setCurrentHour(22); //当前小时
        timePicker.setCurrentMinute(0); //当前分钟
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();

            }
        });
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(StartPage1.this, StartPage2.class);
                intent.putExtra("Hour",Hour);
                intent.putExtra("Minute",Minute);
                startActivity(intent);
            }
        });
        timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
            @Override
            public void onTimeChanged(TimePicker timePicker, int i, int i1) {
                Toast.makeText(StartPage1.this,"您选择的时间是："+i+"时"+i1+"分!",Toast.LENGTH_SHORT).show();
               // time_first=String.valueOf(i)+":"+String.valueOf(i1);
                Hour=i;
                Minute=i1;
            }
        });
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                return true;
        }
        return false;
    }
}